<template>
  <div>
    <van-nav-bar title="拓天销售订单详情" left-arrow left-text="返回" @click-left="back" />
    <div class="wrapper">
      <van-form validate-first style="width:95%">
        <!--        <van-cell-group class="InfoCard">-->
        <!--          <van-field label="任务单号" v-model="model.fbillno" readonly />-->
        <!--          <van-field label="派工日期" :value="$moment(model.fpgdate).format('YYYY-MM-DD')" readonly />-->
        <!--          <van-field label="报修单号" v-model="model.fbxbillno" readonly />-->
        <!--          <van-field label="指令单号" v-model="model.forderbillno" readonly />-->
        <!--          <van-field label="设备代码" v-model="model.fnumber" readonly />-->
        <!--          <van-field label="设备名称" v-model="model.fname" readonly />-->
        <!--          <van-field label="设备型号" v-model="model.fmodel" readonly />-->
        <!--          <van-field label="设备序列号" v-model="model.fserialnum" readonly />-->
        <!--          <van-field label="客户" v-model="model.fcust" readonly />-->
        <!--          <van-field label="联系人" v-model="model.fcontact" readonly />-->
        <!--          <van-field label="联系电话" v-model="model.fphone" readonly />-->
        <!--          <van-field label="现场地址" v-model="model.faddress" readonly />-->
        <!--          <van-field label="出厂日期" v-model="model.fdate" readonly />-->
        <!--          <van-field label="服务类型" v-model="model.ftypename" readonly />-->
        <!--          <van-field label="故障描述" v-model="model.fdescribe" readonly />-->
        <!--          <van-field label="处理结果" v-model="model.fresult" readonly />-->
        <!--          <van-field label="执行人" v-model="model.username" readonly />-->
        <!--          <van-field label="开始日期" v-model="model.fstarttime" readonly />-->
        <!--          <van-field label="结束日期" v-model="model.fendtime" readonly />-->
        <!--        </van-cell-group>-->
        <van-cell-group class="InfoCard" v-show="extraorderList.length">
          <van-tag mark type="primary" size="large">拓天销售订单明细</van-tag>
          <div style="display: inline-block;color: #1989fa;font-size: 14px;margin-left: 10px" @click="clickFade2">{{ isFade2 ? '收起' : '展开' }}<van-icon :name="iconName2" color="#1989fa"></van-icon></div>
          <div class="margin-top-10" v-for="(item, index) in extraorderList" :key="index" v-show="isFade2">
            <div class="order-num">{{index + 1}}</div>
            <van-field :value="item.FEntrySelfS0166" label="项号" readonly/>
            <van-field :value="item.FMapNumber" label="对应代码" readonly/>
            <van-field :value="item.FNumber" label="产品代码" readonly/>
            <van-field :value="item.fname1" label="产品名称" readonly/>
            <van-field :value="item.fmodel" label="规格型号" readonly/>
            <van-field :value="item.fqty1" label="数量" readonly/>
            <van-field :value="item.fprice1" label="未税单价" readonly/>
            <van-field :value="item.fprice2" label="含税单价" readonly/>
            <van-field :value="$moment(item.jhtime).format('YYYY-MM-DD')" label="交货日期" readonly/>
            <van-field :value="item.FCommitQty" label="出库数量" readonly/>
            <van-field :value="item.fprice3" label="未税金额" readonly/>
            <van-field :value="item.fprice4" label="税率" readonly/>
            <van-field :value="item.FTaxAmount" label="折扣额" readonly/>
            <van-field :value="item.FTaxRate" label="折扣率" readonly/>
            <van-field :value="item.FPriceDiscount" label="实际含税单价" readonly/>
            <van-field :value="item.fnote2" label="客户商品代码" readonly/>
            <van-field :value="item.fnote" label="条目备注" readonly/>
            <van-field :value="item.fprice6" label="销项税额" readonly/>
          </div>
        </van-cell-group>
      </van-form>
    </div>
  </div>
</template>

<script>
  import { ttGetDetail, } from "@/api/api";
  import {Notify} from "vant";
  import {mapState} from "vuex";

  export default {
    name: "ttSalesOrderDetail",
    data() {
      return {
        isFade2: true,
        model: {},
        extraorderList: [],
      };
    },
    computed: {
      iconName2(){
        return this.isFade2 ? 'arrow-up' : 'arrow-down'
      },
      ...mapState({
        userId: state => state.user.userId
      })
    },
    created() {
      let id = this.$route.params.id
      console.log(this.$route)
      ttGetDetail({ id }).then(res => {
        if(res.success) {
          console.log(res)
          this.extraorderList = res.result
        }else {
          Notify({ type: 'danger', message: res.message, duration: 4000 })
        }
      })
    },
    methods: {
      //返回
      back() {
        this.$router.go(-1);
      },
      clickFade2() {
        this.isFade2 = !this.isFade2
      },
    }
  }
</script>

<style scoped>
  /deep/.van-field__label {
    width: 8.3em!important;
  }
</style>